package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseAuditApi;
import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.qo.QueryCourseModel;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.content.convert.CourseBaseConvert;
import com.xuecheng.content.service.CourseBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CourseAuditController implements CourseAuditApi {

    @Autowired
    private CourseBaseService courseBaseService;

    /**
     * 分页查询课程基础信息-运营
     *
     * @param params
     * @param model
     * @return
     */
    @PostMapping("m/course/list")
    public PageVO<CourseBaseDTO> queryCourseList(PageRequestParams params, @RequestBody QueryCourseModel model) {
        PageVO<CourseBaseDTO> pageVO = this.courseBaseService.queryCourseBaseList(params, model, null);
        return pageVO;
    }

    /**
     * 审核课程基本信息
     * @param vo 课程基本信息
     */
    @PostMapping("m/courseReview/approve")
    public void approve(@RequestBody CourseAuditVO vo) {
        //将 vo 转为 dto 数据
        CourseBaseDTO courseBaseDTO = CourseBaseConvert.INSTANCE.vo2dto(vo);
        this.courseBaseService.approve(courseBaseDTO);
    }
}
